﻿<%@ Page CodeFileBaseClass="AliCMS.Lib.AdminPageBase" %>
<script language="c#" runat="server">
protected string Condition()
{
	StringBuilder condition = new StringBuilder(Alias.Order.Detail.IsCanceled + "=false");
	string and = " AND ";

	#region 性质
	string kind = Request.QueryString["Kind"];
	if (kind != null && kind != "*")
		condition.Append(and + Alias.Order.Detail.Kind + "='" + kind + "'");
	#endregion

	#region 关键词
	string keyword = Request.QueryString["Keyword"];
	if (!String.IsNullOrEmpty(keyword))
	{
		if (Request.QueryString["KeywordType"] == "Number")
			condition.Append(and + Alias.Order.Detail.OrderNumber + "='" + keyword + "'");
		else if (Request.QueryString["KeywordType"] == "Name")
			condition.Append(and + Alias.Order.Detail.Name + " LIKE '%" + keyword + "%'");
	}
	#endregion
	
	return condition.ToString();
}

protected string Sort()
{
	string sort = String.Empty;
	switch (Request.QueryString["Sort"])
	{
		case "1":
			sort = Alias.Order.Detail.InnerID + " DESC";
			break;
		case "2":
			sort = Alias.Order.Detail.InnerID + " ASC";
			break;
		case "3":
			sort = Alias.Order.Detail.ExpiredTime + " DESC";
			break;
		case "4":
			sort = Alias.Order.Detail.ExpiredTime + " ASC";
			break;
		default:
			sort = Alias.Order.Detail.InnerID + " DESC";
			break;
	}
	
	return sort;
}
</script>
<table border="0" cellpadding="4" cellspacing="1">
	<thead>
		<tr>
			<th>名称</th>
			<th>订单号</th>
			<th>创建时间</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		<ali:List ID="List" Object="Order.Detail" Page="PageNumber" PageSize="20" Condition="Condition()" Sort="Sort()" Validate="True">
			<ali:Record>
				<tr>
					<td>
						<a href="../../IlgharCMS.HostModule/product/view.aspx?ID=<%=InnerID%>"><%=Name%></a>
					</td>
					<td><a href="../../IlgharCMS.HostModule/order/view.aspx?ID=<%=OrderInnerID%>"><%=OrderNumber%></a></td>
					<td><%=CreateTime%></td>
					<td>
						<%If Int32.Equals(DeliveredAmount, Amount)%>
							已发货
						<%ElseIf Convert.ToInt32(DeliveredAmount) > 0%>
							部分发货
						<%Else%>
							未发货
						<%EndIf%>
						<%If Convert.ToBoolean(OnTrial)%>
							，试用中
						<%EndIf%>
						<%If !Convert.IsDBNull(ExpiredTime)%>
							<%If DateTime.Now > Convert.ToDateTime(ExpiredTime)%>
								，已过期
								<%If String.Equals(Kind, "Host") && Guid.Equals(ServerID, Guid.Empty)%>
								，已删除
								<%EndIf%>
							<%Else%>
								，<%=Convert.ToDateTime(ExpiredTime).Subtract(DateTime.Now).Days + 1%>天后过期
							<%EndIf%>
						<%EndIf%>
					</td>
					<td>
						【<a href="../../IlgharCMS.HostModule/product/feedback.aspx?ID=<%=InnerID%>">反馈</a>】

						<%If !Convert.ToBoolean(OnTrial) && Int32.Equals(DeliveredAmount, 0) && Guid.Equals(ParentID, Guid.Empty) && Guid.Equals(ServerID, Guid.Empty)%>
							<ali:List Object="Product" Page="1" PageSize="1" Condition="ID=ProductID">
								<ali:Record>
									<%If Convert.ToBoolean(CanTry)%>
										【<a id="Try<%=List[InnerID]%>">试用</a>】
									<%EndIf%>
								</ali:Record>
							</ali:List>
						<%EndIf%>

						<%If !Convert.IsDBNull(ExpiredTime) && Int32.Equals(DeliveredAmount, Amount) && (!String.Equals(Kind, "Host") || !Guid.Equals(ServerID, Guid.Empty))%>
							【<a id="Update<%=InnerID%>">续费</a>】
						<%EndIf%>
						
						<%If String.Equals(Kind, "Host") && !Guid.Equals(ServerID, Guid.Empty)%>
							<%If !Convert.ToBoolean(OnTrial)%>
								【<a href="../../IlgharCMS.HostModule/product/host.aspx?ID=<%=InnerID%>">管理</a>】
							<%EndIf%>
							<ali:List Source="Manager.SplitToTable(ServerBindings)">
								<ali:Record>
									<a href="http://<%=[0]%>" target="_blank" style="display:block">http://<%=[0]%></a>
								</ali:Record>
							</ali:List>								
						<%EndIf%>
						
						<%If String.Equals(Kind, "WebSite") && !String.Equals(Convert.ToString(File), String.Empty)%>
							【<a href="<%=File%>" target="_blank">下载</a>】
							【<a id="Install<%=InnerID%>">安装</a>】
						<%EndIf%>
					</td>
				</tr>
			</ali:Record>
		</ali:List>
	</tbody>
</table>
<ali:Pagination Page="PageNumber" PageSize="20" RecordCount="List[RecordCount]">
	<div class="Pagination">
		<div class="Left">共 <%=RecordCount%> 条 当前显示第 <%=PageNumber%> 页 第 <%=RangeLower%>-<%=RangeUpper%> 条 </div>
		<div class="Right">
			<ali:FirstPage>
				<ali:Yes>
					<img src="<%=ImagePath%>pagination/first_page_off.gif" alt="首页" />
					<img src="<%=ImagePath%>pagination/previous_page_off.gif" alt="上一页" />
				</ali:Yes>
				<ali:No>
					<a href="javascript:Go(1)"><img src="<%=ImagePath%>pagination/first_page_on.gif" alt="首页" /></a>
					<a href="javascript:Go(<%=PageNumber%> - 1)" id="PrevPage"><img src="<%=ImagePath%>pagination/previous_page_on.gif" alt="上一页" /></a>
				</ali:No>
			</ali:FirstPage>
			<ali:CurrentPage Range="5">
				<ali:Yes>
					<span class="Current"><%=Index%></span>						
				</ali:Yes>
				<ali:No>
					<a href="javascript:Go(<%=Index%>)">[<%=Index%>]</a>
				</ali:No>
			</ali:CurrentPage>
			<ali:LastPage>
				<ali:Yes>
					<img src="<%=ImagePath%>pagination/next_page_off.gif" alt="下一页" />
					<img src="<%=ImagePath%>pagination/last_page_off.gif" alt="尾页" />
				</ali:Yes>
				<ali:No>
					<a href="javascript:Go(<%=PageNumber%> + 1)" id="NextPage"><img src="<%=ImagePath%>pagination/next_page_on.gif" alt="下一页" /></a>
					<a href="javascript:Go(<%=PageCount%>)"><img src="<%=ImagePath%>pagination/last_page_on.gif" alt="尾页" /></a>
				</ali:No>
			</ali:LastPage>
		</div>
	</div>
</ali:Pagination>